<template>
  <div class="leader">
    <el-card shadow="hover">
      <div class="box">
        <div class="header">
          <div class="title">
            <div class="info">排行榜</div>
            <div class="intro">更新</div>
          </div>
        </div>
        <div class="other" v-for="(item, index) in dataList" :key="index">
          <div
            :class="(index+1) == 1? 'first' : (index+1) == 2 ? 'second' : (index+1) == 3 ? 'third' : 'nomarl'"
          >{{(index+1)}}</div>
          <div class="info-box">
            <div class="title" @click="handleToChapter(item.id)">{{item.name}}</div>
          </div>
        </div>
      </div>
    </el-card>

    <el-card shadow="hover" style="margin-top:20px;">
      <div class="more">
        <div class="title">
          <span>更多</span>
          <span>最近更新</span>
        </div>
        <svg-icon icon-class="more" @click="handleToLibrary" />
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  name: "NormalLeader",
  data() {
    return {};
  },
  props: {
    dataList: Array,
    libOption: Object
  },
  watch: {
    dataList(val) {
      this.dataList = val;
    }
  },
  created() {},
  methods: {
    handleToChapter(id) {
      this.$router.push({
        path: "/chapter",
        query: { id }
      });
    },
    handleToLibrary() {
      this.$router.push({
        path: "/library",
        query: this.libOption
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.leader {
  width: 224px;
  border-radius: 12px;
  .box {
    padding: 36px 34px 40px 34px;
    .header {
      display: flex;
      flex-direction: columns;
      justify-content: space-between;
      border-bottom: 1px solid rgba(6, 27, 65, 0.05);
      .title {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        .info {
          font-size: 20px;
          font-family: MicrosoftYaHeiSemibold;
          font-weight: 600;
          color: rgba(6, 27, 65, 1);
          line-height: 16px;
          opacity: 0.65;
          margin-bottom: 10px;
        }
        .intro {
          font-size: 12px;
          font-family: MicrosoftYaHei;
          font-weight: 400;
          color: rgba(6, 27, 65, 1);
          line-height: 16px;
          opacity: 0.45;
          margin-bottom: 18px;
        }
      }
    }
    .other {
      display: flex;
      justify-content: space-between;
      padding-top: 21px;
      align-items: flex-start;
      .first {
        width: 16px;
        height: 16px;
        border-radius: 50%;
        font-size: 12px;
        font-family: MicrosoftYaHeiSemibold;
        font-weight: 600;
        color: rgba(255, 255, 255, 1);
        margin-top: -1px;
        background: rgba(255, 130, 130, 1);
      }
      .second {
        width: 16px;
        height: 16px;
        border-radius: 50%;
        font-size: 12px;
        font-family: MicrosoftYaHeiSemibold;
        font-weight: 600;
        color: rgba(255, 255, 255, 1);
        margin-top: -1px;
        background: rgba(254, 163, 103, 1);
      }
      .third {
        width: 16px;
        height: 16px;
        border-radius: 50%;
        font-size: 12px;
        font-family: MicrosoftYaHeiSemibold;
        font-weight: 600;
        color: rgba(255, 255, 255, 1);
        margin-top: -1px;
        background: rgba(255, 217, 88, 1);
      }
      .nomarl {
        width: 16px;
        height: 16px;
        border-radius: 50%;
        font-size: 12px;
        font-family: MicrosoftYaHeiSemibold;
        font-weight: 600;
        color: rgba(255, 255, 255, 1);
        margin-top: -1px;
        background: rgba(146, 200, 255, 1);
      }
      .info-box {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 128px;
        padding-bottom: 21px;
        border-bottom: 1px solid rgba(6, 27, 65, 0.05);
        .title {
          font-size: 14px;
          font-family: MicrosoftYaHei;
          font-weight: 400;
          color: rgba(6, 27, 65, 0.45);
          line-height: 14px;
          cursor: pointer;
          overflow: hidden;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-line-clamp: 1;
          -webkit-box-orient: vertical;
        }
        .title:hover {
          color: rgba(146, 200, 255, 1);
        }
      }
    }
  }
  .more {
    padding: 32px 26px;
    display: flex;
    justify-content: space-between;
    .title {
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      span:first-child {
        font-size: 20px;
        font-family: MicrosoftYaHeiSemibold;
        font-weight: 600;
        color: rgba(6, 27, 65, 0.65);
        line-height: 24px;
      }
      span:last-child {
        font-size: 12px;
        font-family: MicrosoftYaHei;
        font-weight: 400;
        color: rgba(6, 27, 65, 0.45);
        line-height: 24px;
      }
    }
    .svg-icon {
      font-size: 46px;
      cursor: pointer;
    }
  }
}

.leader .is-hover-shadow:hover {
  transform: translateY(-3px);
  transition: all 0.3s linear;
}

.box .other:last-child .info-box {
  border-bottom: none;
  padding-bottom: 0;
}
</style>